package com.zlzxm.shoesmarket.viewmodel;

import android.sax.ElementListener;

import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

import com.zlzxm.shoesmarket.TestConstant;
import com.zlzxm.shoesmarket.util.RxAndroidHelp;
import com.zlzxm.shoesmarket.view.adapter.entity.EntityMatchUser;
import com.zlzxm.shoesmarket.view.adapter.entity.EntitySizePeopleNum;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

import io.reactivex.rxjava3.annotations.NonNull;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.core.Observer;
import io.reactivex.rxjava3.disposables.Disposable;

/**
 * CREATE BY zlzxm ON 4/22/21
 */
public class VMGoodsRequestNote extends ViewModel {

    private MutableLiveData<List<EntitySizePeopleNum>> liveSizeData = new MutableLiveData<>();

    private MutableLiveData<List<EntityMatchUser>> liveUser = new MutableLiveData<>();

    public MutableLiveData<List<EntitySizePeopleNum>> getLiveSizeData() {
        return liveSizeData;
    }


    public MutableLiveData<List<EntityMatchUser>> getLiveUser() {
        return liveUser;
    }

    public void requestSizeData(){

        Observable.timer(2, TimeUnit.SECONDS)
                .compose(RxAndroidHelp.turn())
                .subscribe(new Observer<Long>() {
                    @Override
                    public void onSubscribe(@NonNull Disposable d) {

                    }

                    @Override
                    public void onNext(@NonNull Long aLong) {

                    }

                    @Override
                    public void onError(@NonNull Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                        liveSizeData.setValue(createTestData());
                    }
                });



    }


    public void requestSizeDataUser(){

        Observable.timer(2, TimeUnit.SECONDS)
                .compose(RxAndroidHelp.turn())
                .subscribe(new Observer<Long>() {
                    @Override
                    public void onSubscribe(@NonNull Disposable d) {

                    }

                    @Override
                    public void onNext(@NonNull Long aLong) {

                    }

                    @Override
                    public void onError(@NonNull Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                        liveUser.setValue(createTestDataUser());
                    }
                });



    }

    
    //<editor-fold defaultState="collapsed" desc="测试">


    private List<EntitySizePeopleNum> createTestData(){

        List<EntitySizePeopleNum> list = new ArrayList<>();

        for (int i = 0; i < 10; i++) {


            list.add(new EntitySizePeopleNum("41码","23人"));
        }

        return  list;
    }


    private List<EntityMatchUser> createTestDataUser(){

        List<EntityMatchUser> list = new ArrayList<>();

        for (int i = 0; i < 10; i++) {

            EntityMatchUser entityMatchUser = new EntityMatchUser();
            entityMatchUser.setAddress("北京市");
            entityMatchUser.setTime("02-21 12:21");
            entityMatchUser.setPrice("¥555");
            entityMatchUser.setFace(TestConstant.PIC_EIGHT);


            list.add(entityMatchUser);
        }

        return  list;
    }

    // </editor-fold>
    
}
